// 主页
// 引入request
import request from '@/utils/request';
// 暂无多个分类
export function getListByGroupId() {
    return request({
      url: '/urls',
      method: 'get'
    })
}
// 查询卡片
export function searchGroup(data) {
  return request({
    url: `/urls/search`,
    method: 'get',
    params: { query: data }
  })
}
  
  // 新增卡片
  export function addListByGroupId(data) {
    return request({
      url: '/urls',
      method: 'post',
      data
    })
  }
  
  // 修改卡片
  export function putListByGroupId(data) {
    return request({
      url: `/urls/${data.id}`,
      method: 'put',
      data
    })
  }
  
  // 删除卡片
  export function delListByGroupId(data) {
    return request({
        url: `/urls/${data.id}`,
        method: 'delete'
    })
  }
  
// 查询所有分组
export function getGroup() {
  return request({
      url: `/groups`,
      method: 'get'
  })
}

// 根据ID查分组
export function getGroupByID(id) {
  return request({
      url: `/urls/group/${id}`,
      method: 'get'
  })
}

// 删除分组
export function delGroup(id) {
  return request({
      url: `/groups/${id}`,
      method: 'delete'
  })
}

// 添加分组
export function addGroup(data) {
  return request({
    url: '/groups',
    method: 'post',
    data
  })
}

// 修改分组 
export function editGroup(data) {
  return request({
    url: `/groups/${data.id}`,
    method: 'put',
    data
  })
}

// 获取图标
export function getFavicon(data) {
  return request({
    url: '/urls/get_icon',
    method: 'post',
    data
  })
}

// 获取设置
export function getSetting() {
  return request({
    url: '/settings',
    method: 'get'
  })
}

// 根据key获取设置
export function getSettingByKey(key) {
  return request({
    url: `/settings/${key}`,
    method: 'get'
  })
}
// 新增设置
export function addSetting(data) {
  return request({
    url: '/settings',
    method: 'post',
    data
  })
}
// 修改设置
export function putSetting(data) {
  return request({
    url: `/settings/${data.key}`,
    method: 'put',
    data
  })
}
// 删除设置
export function delSetting(id) {
  return request({
    url: `/settings/${id}`,
    method: 'delete'
  })
}